package com.bestbuy.pojo;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import antlr.collections.List;


/**
 * @author ThanhNgo
 *
 */
@Entity
@Table(name = "product")
public class Product {
	@Id
    @Column(name="IDPRODUCT")
	@GeneratedValue
    private Integer idproduct;
	
	@ManyToOne
    @JoinColumn(name="IDCATALOG")
	@Fetch(FetchMode.JOIN)
    private Catalog catalog;
	
	/**
	 * @return the promotion
	 */
	public Promotion getPromotion() {
		return promotion;
	}

	/**
	 * @param promotion the promotion to set
	 */
	public void setPromotion(Promotion promotion) {
		this.promotion = promotion;
	}

	@ManyToOne
    @JoinColumn(name="IDPROMOTION")
	@Fetch(FetchMode.JOIN)
    private Promotion promotion;
    
//	@ManyToOne
//    @JoinColumn(name="PRODUCTDETAIL")
//	@Fetch(FetchMode.JOIN)
//    private ProductDetail productdetail;
	@OneToOne(mappedBy = "product", cascade = CascadeType.ALL)
	private ProductDetail productdetail;
    
    @Column(name = "PRODUCTCODE")
    private String productcode;
    
    @Column(name = "PRODUCTNAME")
    private String productname;
    
    @Column(name = "QUANTITY")
    private Integer quantity;
    
    @Column(name = "PRICE")
    private Float price;
    
    @Column(name = "Linkimage")
    
    private String linkImage;
    
    @Column(name = "ISDELETED")
    private Integer isdeleted;
    
    @OneToMany(mappedBy="product", fetch = FetchType.LAZY)
    private Set<ImageProduct> imageproducts = new HashSet<ImageProduct>(0);
    
    
    
    @OneToMany(mappedBy="product", fetch = FetchType.LAZY)
    private Set<Comment> comments = new HashSet<Comment>(0);
    
    @OneToMany(mappedBy="product", fetch = FetchType.LAZY)
    private Set<CartDetail> cartDetails = new HashSet<CartDetail>(0);



	public Integer getIdproduct() {
		return idproduct;
	}

	public void setIdproduct(Integer idproduct) {
		this.idproduct = idproduct;
	}
	
	public String getLinkImage() {
		return linkImage;
	}

	public void setLinkImage(String linkImage) {
		this.linkImage = linkImage;
	}

	public Catalog getCatalog() {
		return catalog;
	}

	public void setCatalog(Catalog catalog) {
		this.catalog = catalog;
	}

	public ProductDetail getProductdetail() {
		return productdetail;
	}

	
	public void setProductdetail(ProductDetail productdetail) {
		this.productdetail = productdetail;
	}

	public String getProductcode() {
		return productcode;
	}
	
	

	public void setProductcode(String productcode) {
		this.productcode = productcode;
	}

	public String getProductname() {
		return productname;
	}

	public void setProductname(String productname) {
		this.productname = productname;
	}

	public Integer getQuantity() {
		return quantity;
	}

	public void setQuantity(Integer quantity) {
		this.quantity = quantity;
	}

	public Float getPrice() {
		return price;
	}

	public void setPrice(Float price) {
		this.price = price;
	}

	public Integer getIsdeleted() {
		return isdeleted;
	}

	public void setIsdeleted(Integer isdeleted) {
		this.isdeleted = isdeleted;
	}

	public Set<ImageProduct> getImageproducts() {
		return imageproducts;
	}

	public void setImageproducts(Set<ImageProduct> imageproducts) {
		this.imageproducts = imageproducts;
	}

	public Set<Comment> getComments() {
		return comments;
	}

	public void setComments(Set<Comment> comments) {
		this.comments = comments;
	}

	public Set<CartDetail> getCartDetails() {
		return cartDetails;
	}

	public void setCartDetails(Set<CartDetail> cartDetails) {
		this.cartDetails = cartDetails;
	}

	/**
	 * @param idproduct
	 * @param catalog
	 * @param promotion
	 * @param productdetail
	 * @param productcode
	 * @param productname
	 * @param quantity
	 * @param price
	 * @param linkImage
	 * @param isdeleted
	 * @param imageproducts
	 * @param comments
	 * @param cartDetails
	 */
	public Product(Integer idproduct, Catalog catalog, Promotion promotion,
			ProductDetail productdetail, String productcode,
			String productname, Integer quantity, Float price,
			String linkImage, Integer isdeleted,
			Set<ImageProduct> imageproducts, Set<Comment> comments,
			Set<CartDetail> cartDetails) {
		super();
		this.idproduct = idproduct;
		this.catalog = catalog;
		this.promotion = promotion;
		this.productdetail = productdetail;
		this.productcode = productcode;
		this.productname = productname;
		this.quantity = quantity;
		this.price = price;
		this.linkImage = linkImage;
		this.isdeleted = isdeleted;
		this.imageproducts = imageproducts;
		this.comments = comments;
		this.cartDetails = cartDetails;
	}

	public Product() {
		super();
		// TODO Auto-generated constructor stub
	}
    
    
}
